<?php
/* @var $this StatusController */
/* @var $model Status */
/* @var $form CActiveForm */
?>
<div class="wide form">

<?php 
		$form=$this->beginWidget('CActiveForm', array(

		'action'=>Yii::app()->createUrl($this->route),

		'method'=>'get',

		));
	?>


	<div class="row">
	<?php $result=User::model()->getSalespeople();?>
		<?php echo $form->label($model,'agent_id'); ?>
		<?php //echo $form->textField($model,'agent_id'); ?>
		<?php //echo $form->dropDownList($model, 'agent_id',CHtml::listData($result,'user_id','user_name'),array('prompt'=>'All'));?>
		<?php 
	if($model->agent_id==null)
	{
	echo $form->dropDownList($model, 'agent_id',CHtml::listData($result,'user_id','user_name'),array('prompt'=>'All'));
	}else{
			echo $form->dropDownList($model, 'agent_id',array(Yii::app()->user->id=>Yii::app()->user->name));
}
	?>
	</div>
		<div class="row">
			<?php echo $form->label($model,'status'); ?>
			<?php //echo $form->textField($model,'status',array('size'=>60,'maxlength'=>255)); ?>
			<?php echo $form->dropDownList($model, 'status',array(1=>'No Answer',2=>'Busy or Not Available',3=>'Invalid Number',4=>'Do not call again',5=>'No interest',6=>'Qualified lead',7=>'Won'),array('prompt'=>'All'));?>
		</div>

	<div class="row">
		<?php echo $form->label($model,'last_called_date_and_time'); ?>

  		<input type="text" id="lasttime1" name="Status[last_called_date_and_time]" size="10" value="<?php echo date("Y-m-d",strtotime("-7 day"));?>" onClick="WdatePicker({startDate:'%y-%M-01',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})" " style="width:130px;" />
  		<?php echo Yii::t('base','TO');?>
  		<input type="text" id="lasttime2" name="last_called_date_and_time" size="10" value="<?php echo date("Y-m-d");?>" onClick="WdatePicker({startDate:'%y-%M-01',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})" " style="width:130px;" /> 		
		</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton(Yii::t('base','search'),array('id'=>'submit')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- search-form -->
<?php 
//$arr=Yii::t('base','The first value cannot be less than second value');
Yii :: app()->clientScript->registerScript('search1', "
		$('#submit').click(function(){
		if($('#lasttime1').val()>$('#lasttime2').val())
		{
			alert('".Yii::t('base','The first value cannot be less than second value')."');
			$('#lasttime1').focus();
			return false;
		}
			
		});
		");
?>